<!DOCTYPE HTML>
<html>

<head>
    <include file="Public/head" />
</head>

<body>
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span>
        系统设置
        <span class="c-gray en">&gt;</span>
        角色管理
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"
            title="刷新">
            <i class="Hui-iconfont">&#xe68f;</i>
        </a>
    </nav>
    <div class="page-container">
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="l">
                <a href="{:U('Role/add')}" class="btn btn-primary radius">
                    <i class="Hui-iconfont">&#xe600;</i> 添加角色</a>
            </span>
        </div>
        <div class="mt-20">
            <table class="table table-border table-bordered table-hover table-bg table-sort">
                <thead>
                    <tr class="text-c">
                        <th width="80">ID</th>
                        <th width="100">角色名</th>
                        <th width="130">创建时间</th>
                        <th width="70">状态</th>
                        <th width="100">操作</th>
                    </tr>
                </thead>
                <tbody>
                    <foreach name="roles" item="vo">
                        <tr class="text-c">
                            <td>{$vo.id}</td>
                            <td>
                                <u style="cursor:pointer" class="text-primary">{$vo.name}</u>
                            </td>

                            <td>{$vo.create_time}</td>
                            <td class="td-status">
                                <if condition="$vo.status eq 1">
                                    <span class="label label-success radius">已启用</span>
                                    <else />
                                    <span class="label label-error radius">已停用</span>
                                </if>
                            </td>
                            <td class="td-manage">
                                <if condition="$vo.status eq 1">
                                    <a style="text-decoration:none" title="停用" onclick="forbidden_item({$vo['id']})">
                                        <i class="Hui-iconfont">&#xe631;</i>
                                    </a>
                                    <else />
                                    <a style="text-decoration:none" title="启用" onclick="forbidden_item({$vo['id']})">
                                        <i class="Hui-iconfont">&#xe615;</i>
                                    </a>
                                </if>
                                <form id="forbidden_form_{$vo.id}" action="{:U('Role/forbidden',array('id'=>$vo['id']))}" method="POST" style="display: none;">
                                    <input type="text" value="{$vo.id}" name="id">
                                    <input type="text" value="{$vo.status}" name="status">
                                </form>

                                <a title="编辑权限" href="{:U('Role/edit',array('id'=>$vo['id']))}" class="ml-5" style="text-decoration:none">
                                    <i class="Hui-iconfont">&#xe6df;</i>
                                </a>
                                <a title="删除" href="javascript:;" onclick="del_item({$vo['id']})" class="ml-5" style="text-decoration:none">
                                    <i class="Hui-iconfont">&#xe6e2;</i>
                                    <form id="del_form_{$vo.id}" action="{:U('Role/del',array('id'=>$vo['id']))}" method="POST" style="display: none;">
                                        <input type="text" value="{$vo.id}" name="id">
                                    </form>
                                </a>
                            </td>
                        </tr>
                    </foreach>
                </tbody>
            </table>


        </div>
        <include file="Public/script" />
</body>
<script>
    function del_item(id) {
        //询问框
        layer.confirm('确认要删除吗？', {
            btn: ['删除', '取消'] //按钮
        }, function () {
            $('#del_form_' + id).submit();
        }, function () {
            console.log('用户取消啦...');
        });
    }


    function forbidden_item(id) {
        //询问框
        layer.confirm('确认要修改吗？', {
            btn: ['修改', '取消'] //按钮
        }, function () {
            $('#forbidden_form_' + id).submit();
        }, function () {
            console.log('用户取消啦...');
        });
    }
</script>

</html>